<title>管理组</title>
  
<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>系统设置</cite></a>
    <a><cite>管理组</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-header">管理组</div>
    <div class="layui-card-body">
      <div style="padding-bottom: 10px;">
        <a href="#J_view" class="layui-btn J_popup" title="添加管理组"><i class="layui-icon layui-icon-add-circle"></i>添加管理组</a>
      </div>
      
      <table id="J_table_list" lay-filter="J_table_list"></table>

    </div>
  </div>
</div>

<script type="text/html" id="imgTpl">
  <img class="layui-nav-img" style="display: inline-block; width: 26px; height: 26px;" src="/portrait/{{ d.id }}.jpg">
</script>

<script type="text/html" id="J_table_tool">
  {{# if(d.type=='default'){ }}
  <a href="#J_view" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="popup" title="编辑用户"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  <a href="role/remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req"title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
  {{# }else{ }}
  <a href="javascript:;" class="layui-btn layui-btn-disabled layui-btn-xs" disabled><i class="layui-icon layui-icon-edit"></i>编辑</a>
  <a href="javascript:;" class="layui-btn layui-btn-disabled layui-btn-xs" disabled><i class="layui-icon layui-icon-delete"></i>删除</a>
  {{# } }}
</script>

<script type="text/html" id="J_view">
<form class="layui-form" action="{:url('/role/dorun')}" method="post">
  <input type="hidden" name="id" value="{{d.id||0}}">
  
            <div class="layui-form-item">
              <label class="layui-form-label">角色名称</label>
              <div class="layui-input-inline">
                <input type="text" name="name" value="{{d.name||''}}" lay-verify="required" autocomplete="off" class="layui-input">
              </div>
            </div>
  <hr>

  {volist name="log" id="item"}
  <div class="layui-form-item">
    <label class="layui-form-label">{$item.title}</label>
    <div class="layui-input-inline">
        {volist name="item.list" id="value"}
        <input class="cityId" type="checkbox" name="auths[]" lay-skin="primary" title="{$value.title}" value="{$item.name}_{$value.name}" {{# if(d.auths && d.auths.indexOf('{$item.name}_{$value.name}')>0){ }}checked="checked"{{# } }}>
        {/volist}
    </div>
  </div>
  <hr>
  {/volist}
  
            <div class="layui-form-item">
              <div class="layui-input-block">
                <input type="checkbox" lay-skin="primary" lay-filter="J_checkAll" title="全选">
                <button class="layui-btn" lay-submit lay-filter="J_ajax_submit_btn"><i class="layui-icon layui-icon-ok-circle"></i>提交</button>
              </div>
            </div>
            
          </form>
</script>

<script>
;!function(){
  var $ = layui.$
  ,form = layui.form
  ,table = layui.table;

  //执行渲染
table.render({
  elem: '#J_table_list'
  ,url: '{:url('/role/list')}'
  ,cols: [[
      {field:'name',title:'组名',width:200}
      ,{title:'操作',minWidth:120,toolbar:'#J_table_tool'}
  ]]
  ,height: 'auto'
  ,text: {
    none: '暂无数据'
  }
});

    //监听复选框选择
    form.on('checkbox(J_checkAll)', function(obj){
        $('.cityId').prop('checked', this.checked);
        form.render('checkbox');
    });


}();
</script>